<?php

class People_VillageController extends Base_Controller_Action
{

    public function manageAction()
    {
        $street = new Model_Street();
        try {
            $street->read($this->_getParam('aid'));
        }
        catch (Base_Exception $e) {
            return $this->_helper->ErrorPage(404);
        }
        
        //question list
        $dbTable = new Table_Village();
        $whereArray['`sid` = ?'] = $street->sid;
        $this->view->street = $street;
        $this->view->entries = $dbTable->view($whereArray, 'vid ASC');

    }
    
    public function createAction()
    {
        //create form
        $this->form = new Form_Village_Create();
        
        try {
            $this->create('village');
        }
        catch (Base_Model_Exception $e) {
            return $this->_helper->ErrorPage($e->getMessage());
        }
        
        //check oid
        $this->form->sid->setValue($this->_getParam('sid'));
    }
    
    public function modifyAction()
    {
        //create form
        $this->form = new Form_Village_Modify();
        
        try {
            $this->modify('village');
        }
        catch (Base_Model_Exception $e) {
            return $this->_helper->ErrorPage($e->getMessage());
        }
    }
    
    public function deleteAction()
    {
        $this->form = new Form_Village_Delete();
        
        //drop post
        try {
            $this->delete('village');
        }
        catch (Base_Exception $e) {
            return $this->_helper->ErrorPage($e->getMessage());
        }
    }
}